home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / STL Headers / pair.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-01  |  1.2 KB  |  45 lines  |  [TEXT/MMCC]

  1. /*
  2.  *
  3.  * Copyright (c) 1994
  4.  * Hewlett-Packard Company
  5.  *
  6.  * Permission to use, copy, modify, distribute and sell this software
  7.  * and its documentation for any purpose is hereby granted without fee,
  8.  * provided that the above copyright notice appear in all copies and
  9.  * that both that copyright notice and this permission notice appear
  10.  * in supporting documentation.  Hewlett-Packard Company makes no
  11.  * representations about the suitability of this software for any
  12.  * purpose.  It is provided "as is" without express or implied warranty.
  13.  *
  14.  */
  15.  
  16. #ifndef PAIR_H
  17. #define PAIR_H
  18.  
  19. #include <bool.h>
  20.  
  21. template <class T1, class T2>
  22. struct pair {
  23.     T1 first;
  24.     T2 second;
  25.     pair(){}
  26.     pair(const T1& a, const T2& b) : first(a), second(b) {}
  27. };
  28.  
  29. template <class T1, class T2>
  30. inline bool operator==(const pair<T1, T2>& x, const pair<T1, T2>& y) { 
  31.     return x.first == y.first && x.second == y.second; 
  32. }
  33.  
  34. template <class T1, class T2>
  35. inline bool operator<(const pair<T1, T2>& x, const pair<T1, T2>& y) { 
  36.     return x.first < y.first || (!(y.first < x.first) && x.second < y.second); 
  37. }
  38.  
  39. template <class T1, class T2>
  40. inline pair<T1, T2> make_pair(const T1& x, const T2& y) {
  41.     return pair<T1, T2>(x, y);
  42. }
  43.  
  44. #endif
  45.